home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / Menu Controls / UShapesDocument.h < prev    next >
Encoding:
Text File  |  1995-06-24  |  3.8 KB  |  130 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
  2. // UDrawShapes.h
  3.  
  4. #ifndef __USHAPESDOCUMENT__
  5. #define __USHAPESDOCUMENT__
  6.  
  7. #ifndef __UFILEBASEDDOCUMENT__
  8. #include <UFileBasedDocument.h>
  9. #endif
  10.  
  11. #ifndef __USHAPELIST__
  12. #include "UShapeList.h"
  13. #endif
  14.  
  15. class TShape;
  16. class TShapeReplaceCommand;
  17. class TShapeView;
  18.  
  19. //--------------------------------------------------------------------------------------------------
  20. // Document state: stored in the Resource Fork of the document file; holds the
  21. //      following general properties of the document, necessary for rereading
  22. //      a saved document and restoring the appearance of the window (location,
  23. //      size, and scrolling) to its state when last saved }
  24.  
  25.     struct DocState {
  26.         short    theNumberOfShapes;
  27.         VPoint    theLocation;
  28.         VPoint    theSize;
  29.         VPoint    theScrollPosition;
  30.         };
  31.  
  32. typedef DocState* PDocState;                    // Pointer to DocState information
  33. typedef PDocState* HDocState;                    // Handle to DocState information
  34.  
  35. //--------------------------------------------------------------------------------------------------
  36.  
  37. //--------------------------------------------------------------------------------------------------
  38. // TShapeDocument
  39. //--------------------------------------------------------------------------------------------------
  40. class TShapeDocument : public TFileBasedDocument
  41. {
  42.     MA_DECLARE_CLASS;
  43.  
  44.     friend class CShapeIterator;
  45.     friend class TShapeCutCopyCommand;
  46.  
  47.   public:
  48.     TShapeDocument();            // Constructor
  49.  
  50.     void IShapeDocument(TFile* itsFile);
  51.  
  52.     virtual void Free();    // Override
  53.     virtual void FreeData();    // Override
  54.  
  55.     // • Adding/deleting shapes
  56.     void AddShape(TShape* shape);
  57.     void DeleteShape(TShape* shape);
  58.  
  59.     // • Overrides of basic TDocument methods
  60.     virtual void DoMakeViews(Boolean forPrinting);    // Override
  61.  
  62.     virtual void DoSetupMenus();    // Override
  63.  
  64.     virtual void DoNeedDiskSpace(TFile* itsFile,
  65.                                  long& dataForkBytes,
  66.                                  long& rsrcForkBytes);    // Override
  67.  
  68.     virtual void DoRead(TFile* aFile, Boolean forPrinting);    // Override
  69.     virtual void DoWrite(TFile* aFile, Boolean makingCopy);    // Override
  70.  
  71.     virtual void ReadFrom(TStream* aStream);    // Override
  72.     virtual void WriteTo(TStream* aStream);    // Override
  73.  
  74.     // • Shape list iteration
  75.     void EachShapeDo(DoToShapeType DoToShape, void* staticLink);
  76.  
  77.     void EachShapeMaybeDo(DoToShapeType DoToShape, void* staticLink);
  78.  
  79.     void EachPotentialShapeDo(DoToShapeType DoToShape, void* staticLink);
  80.  
  81.     void EachVirtualShapeDo(DoToShapeType DoToShape, void* staticLink);
  82.  
  83.     TShape* FirstSelectedShape();
  84.  
  85.     // • Misc
  86.  
  87.     inline TShapeList* GetShapeList() { return fShapeList; };
  88.     inline Boolean IsFiltering() { return fFiltering; };
  89.     inline void SetFiltering(Boolean filtering) { fFiltering = filtering; };
  90.  
  91.     void RestoreWindow(TWindow* aWindow);
  92.  
  93.     PicHandle ShapesAsPict(TList* aShapeList);
  94.  
  95.     void SurveyShapes(Boolean selecteesOnly, short& numberOfShapes, CRect& combinedExtent);
  96.  
  97.     TShapeReplaceCommand* fReplaceCommand;
  98.  
  99.     TShapeView*    fShapeView;
  100.     
  101.     // • Shape utilities
  102.  
  103.     TShape* ShapeUnderMouse(CPoint qdPt);
  104.     void DeselectShapes();
  105.     void RestoreSelection(TShapeView* shapeView);
  106.     void DrawShapes(CRect& qdArea, Boolean dragging);
  107.     void HiliteShapes(TShapeView* shapeView, HLState fromHL, HLState toHL);
  108.     void SaveSelection(TShapeView* shapeView, Boolean andInval);
  109.     void SelectAllShapes(TShapeView* shapeView);
  110.     Boolean CursorInShape(CPoint qdPoint, RgnHandle cursorRegion);
  111.     void AnyShapesSelected(Boolean& anySelection, Boolean& anyShapes);
  112.     void ShapesBeInView(TShapeView* shapeView);
  113.     TView* MakeClipView();
  114.  
  115.   private:
  116.     TShapeList*    fShapeList;
  117.     DocState    fDocState;
  118.     Boolean        fReopening;
  119.     Boolean        fFiltering;
  120.  
  121.     void CreateProceduralShapeView();
  122.         // Used when creating views procedurally to create the shapesView for both
  123.         // printing and non-printing cases
  124.  
  125.     void AddPrintHandlerToView(TView* theView);
  126.         // Used to add a standard print handler to the shape view
  127. };
  128.  
  129. #endif
  130.